<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix" style="text-align: center;line-height: 30px">
        <h3>修改商品销售价</h3>
      </div>
      <div class="text item">
        <el-form ref="ruleForm" label-width="100px" class="demo-ruleForm">

          <el-row>
            <el-col :span="12"><div class="grid-content bg-purple">

              <el-row>
                <el-col :span="24"><div class="grid-content bg-purple" style="text-align: center">
                  <span>商品编号:&nbsp;&nbsp;&nbsp;&nbsp;</span>
                  <span>{{cargoSerial}}</span>
                </div></el-col>
              </el-row>
              <br>
              <br>
              <el-row>
                <el-col :span="24"><div class="grid-content bg-purple" style="text-align: center">
                  <span>商品名称:&nbsp;&nbsp;&nbsp;&nbsp;</span>
                  <span>{{cargoName}}</span>
                </div></el-col>
              </el-row><br><br>
              <el-row>
                <el-col :span="24"><div class="grid-content bg-purple" style="text-align: center">
                  <span>厂家:&nbsp;&nbsp;&nbsp;&nbsp;</span>
                  <span>{{cargoFactory}}</span>
                </div></el-col>
              </el-row><br>
            </div></el-col>

            <el-col :span="12"><div class="grid-content bg-purple-light" style="text-align: center">
              <img width="150px" height="150px" :src="cargoImg" alt="">
            </div></el-col>
          </el-row>
          <br>

          <el-row>
            <el-col :span="12"><div class="grid-content bg-purple" style="text-align: center" >
              <span>类别:&nbsp;&nbsp;&nbsp;&nbsp;</span>
              <span>{{cargoType}}</span>
            </div></el-col>
            <el-col :span="12"><div class="grid-content bg-purple-light" style="text-align: center">
              <span>库存数量:&nbsp;&nbsp;&nbsp;&nbsp;</span>
              <span>{{cargoNumber}}</span>
            </div></el-col>
          </el-row>
          <br>

          <el-row>
            <el-col :span="12"><div class="grid-content bg-purple" style="text-align: center">
              <span>建议采购价:&nbsp;&nbsp;&nbsp;&nbsp;</span>
              <span>{{cargoBuymoney}}</span>
            </div></el-col>
            <el-col :span="12"><div class="grid-content bg-purple-light" style="text-align: center">
              <el-form-item label="建议销售价">
                <el-input v-model="goSalemoney"></el-input>
              </el-form-item>
            </div></el-col>
          </el-row>
          <br>

          <el-row>
            <div style="text-align: center">
              <el-form-item>
                <el-button type="primary" @click="onSubmit">修改</el-button>
              </el-form-item>
            </div>
          </el-row>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "UpdateCargoSaleMoney",
  props:{
    buyId:JSON
  },
  data(){
    return{
      cargoSerial:'',
      cargoName:'',
      cargoFactory:'',
      cargoType:'',
      cargoBuymoney:'',
      goSalemoney:'',
      cargoNumber:'',
      cargoImg:'https://p0.ssl.qhimgs1.com/t018ebe480682aefc74.jpg'
    }
  },
  mounted() {
    this.init()
  },
  methods:{
    init(){

      let id = this.$store.state.goodsId
      let url = "api/stock/findById?id="+id
      this.$axios.get(url).then(r=>{
        let datas = r.data
        this.cargoSerial = datas.goodsId
        this.cargoName = datas.name
        this.cargoFactory = datas.factory
        this.cargoType = datas.type
        this.cargoBuymoney = datas.number
        this.goSalemoney = datas.buyPrice
        this.cargoNumber = datas.sellPrice

      })
    },
    onSubmit(){
      //库存管理中，修改商品销售价
      let goodsId = this.$store.state.goodsId
      let url = "api/stock/updatePrice?id="+goodsId+"&price="+this.cargoNumber
      this.$axios.get(url).then(r=>{
        if (r.data == true){
          alert("修改成功")
          this.$router.push("InventoryView")
        }
      })
    }
  }
}
</script>

<style scoped>

</style>